#pragma once
#include "afxmt.h"
#include <vector>
using namespace std;


#define VEHADMIN CCLVEH::Instance()

struct _VehData
{
	char VehName_[512];
	char MoudleName_[512];
	int   MoudleOffset_;
	DWORD VehHookAdress_;
	DWORD HookCodeLen_;
	BOOL  IsOnce_;
	int OldCode_;
	void(*Fun_)(struct _EXCEPTION_POINTERS * ExceptionInfo);
};


LONG NTAPI veh_optimization(struct _EXCEPTION_POINTERS * ExceptionInfo);


class CCLVEH
{
public:
	static CCLVEH* Instance();
	CCLVEH::~CCLVEH()
	{
		ExitVeh();
	}
public:
	vector<_VehData> VehList;
	CCriticalSection cs_;
	LPVOID m_Handle = 0;
public:
	void AddVeh(char * VehName, char *MoudleName, DWORD MoudleOffset, DWORD VehHookAdress, DWORD HookCodeLen_, int IsOnce, void(*Fun)(struct _EXCEPTION_POINTERS * ExceptionInfo));

public:
	void BreakAll();
	void BreakOne(DWORD CodeAdress);
	void InitVeh(); //AddVeh之后调用
	void BreakRun(DWORD CodeAdress, _EXCEPTION_POINTERS * ExceptionInfo);
	void ExitVeh();
};

//std::string vehname = _T("fucklua");

//CCLVEH::Instance()->AddVeh((char*)vehname.c_str(), "game.dat", 0x4617, 0, 1, 0, veh_callback2);

//CCLVEH::Instance()->InitVeh();